package com.wecloud.core.action.bussiness;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.wecloud.core.action.impl.BaseTransAction;
import com.wecloud.core.constant.WeContext;
import com.wecloud.core.data.jnl.JnlService;
import com.wecloud.core.exception.WeException;
import com.wecloud.core.user.WeUser;

/**
 * 查询文件服务
 * @author qq374
 *
 */
public class GetListAction extends BaseTransAction{
	@Autowired
    private JnlService jnlService;//mysql
	@Override
	public void excute(WeContext context)  throws WeException{
		String fileType = context.getString("fileType");
		Integer pageNo = context.getInteger("pageNo");
		Integer pageSize = context.getInteger("pageSize");
		Map map = new HashMap();
		if(pageNo == 0 || pageSize == 0){
			pageNo = 1;
			pageSize = 10; 
		}
		map.put("fileType", fileType);
		Integer from = (pageNo-1) * pageSize;
		Integer end = pageSize;
		map.put("from", from);
		map.put("end", end);
		WeUser user = context.getUser();
		map.put("userid", user.getUserId());
		List list = jnlService.queryForList("file.getFileList", map);
		Map r = new HashMap();
		r.put("sum", list.size());
		r.put("pageNo", pageNo);
		r.put("pageSize", pageSize);
		r.put("List", list);
		context.setData("content", r);
	}
}
